import React, { useEffect, useState } from 'react'
import { Table, Tag, Button } from 'antd'
import request from '@/utils/request'
export default () => {

    const [tableData, setTableData] = useState({ list: [], total: 0 })
    const columns: any = [
        {
            title: '订单编号',
            dataIndex: 'order_no',
        },
        {
            title: '店铺名称',
            dataIndex: 'store_title',
        },
        {
            title: '商品信息',
            dataIndex: 'goods_title',
        },
        {
            title: '订单金额',
            dataIndex: 'order_amount',
            align: "center",
        },
        {
            title: '实际金额',
            dataIndex: 'pay_amount',
            align: "center",
        },
        {
            title: '使用余额',
            dataIndex: 'use_balance',
            align: "center",
        },
        {
            title: '订单类型',
            dataIndex: 'order_type',
            align: "center",
        },
        {
            title: '订单状态',
            dataIndex: 'order_status',
            align: "center",
            render: (text: any) => <Tag color="cyan">{text}</Tag>,
        },
        {
            title: '下单时间',
            dataIndex: 'order_at',
        },
        {
            title: '操作',
            align: "center",
            render: (text: any) => <Button size="small">详情</Button>,
        }
    ];

    const data = [
        {
            id: 1,
            order_no: "64656565645656",
            store_title: "小米旗舰店",
            goods_title: "小米10",
            order_amount: "20.20",
            actual_amount: "19.90",
            use_balance: "0.00",
            order_type: "订单类型",
            order_status: "普通订单",
            order_at: "2015-12-23 4:50"
        }
    ];

    useEffect(() => {
        request(`/member/order-list`).then((result) => {
            if (result.code === 200) {
                setTableData({ list: result.data, total: result.total })
            }
        })
    }, [])

    return (
        <div>
            <Table
                columns={columns}
                dataSource={tableData.list}
                rowKey="id"
            />
        </div>
    )
}